<?php

//文件转发
header("Content-type:text/html; charset=utf-8;");
require '../../../ppf/fun.php';
require '../../../ppf/pdo_mysql.php';
$pd = new pdo_mysql();
session_start();

if (empty($_SESSION['uid'])) {
    $tips = array(
        'tips' => '请登录后再进行操作',
        'url' => 'index.php'
    );
    $tips = urlencode(serialize($tips));
    header('Location:/tips.php?gets=' . $tips);
    exit;
}
$dir = '/upload/file_fend_attachment/';
$dir_root = $_SERVER['DOCUMENT_ROOT'];
$id = rtrim($_POST['id'], ",");
//var_dump("select attachment_name,attachment_id from file_upload where id in({$id})");exit;
$res = $pd->db->query("select attachment_name,attachment_id from file_upload where id in({$id})")->fetchAll(PDO::FETCH_ASSOC);
if (!$res) {
    echo json_encode(array("tips" => "失败", "status" => false));
} else {
    $id = array();
    $name = array();
    foreach ($res as $v) {
        $attachment_id = rtrim($v['attachment_id'], ",");
        $attachment_name = rtrim($v['attachment_name'], "*");
        $ids = explode(",", $attachment_id);
        $names = explode("*", $attachment_name);
        if (is_array($names)) {
            foreach ($names as $k => $value) {
                $name[] = $value;
                $id[] = $ids[$k];
            }
        }
    }


    echo json_encode(array("tips" => "成功", "status" => true, "id" => $id, "dir" => $dir, "name" => $name));
}
?>